﻿using System;
using System.Linq;

namespace EstateNuke.Data
{
    public partial class AlertType
    {
        #region Fileds & Properties

        /// <summary>
        /// </summary>
        public string DisplayName
        {
            get
            {
                return string.Format("{0}{1}", Name, IsDeleted ? " (已删除)" : "");
            }
        }

        #endregion

        #region Delete

        ///// <summary>
        ///// </summary>
        //public void Delete(User modifiedUser)
        //{
        //    if (modifiedUser == null)
        //    {
        //        throw new ArgumentNullException("modifiedUser");
        //    }
        //    IsDeleted = true;
        //    ModifiedDate = DateTime.Now;
        //    ModifiedByUser = modifiedUser;
        //}

        ///// <summary>
        ///// </summary>
        //public void CancelDelete(User modifiedUser)
        //{
        //    if (modifiedUser == null)
        //    {
        //        throw new ArgumentNullException("modifiedUser");
        //    }
        //    IsDeleted = false;
        //    ModifiedDate = DateTime.Now;
        //    ModifiedByUser = modifiedUser;
        //}

        #endregion
    }

    public class AlertTypeEnum
    {
        #region Fields & Properties

        private readonly EstateNukeCore _context;

        private AlertType _customerCommunicationScheduledCallback;

        /// <summary>
        /// </summary>
        public AlertType CustomerCommunicationScheduledCallback
        {
            get
            {
                return _customerCommunicationScheduledCallback ?? (_customerCommunicationScheduledCallback = _context.AlertTypes.FirstOrDefault(alertType => alertType.Id == 10));
            }
        }

        private AlertType _smallOrderExpired;

        /// <summary>
        /// </summary>
        public AlertType SmallOrderExpired
        {
            get
            {
                return _smallOrderExpired ?? (_smallOrderExpired = _context.AlertTypes.FirstOrDefault(alertType => alertType.Id == 20));
            }
        }

        private AlertType _largeOrderEngagedContract;

        /// <summary>
        /// </summary>
        public AlertType LargeOrderEngagedContract
        {
            get
            {
                return _largeOrderEngagedContract ?? (_largeOrderEngagedContract = _context.AlertTypes.FirstOrDefault(alertType => alertType.Id == 30));
            }
        }

        private AlertType _contractReceiptScheduled;

        /// <summary>
        /// </summary>
        public AlertType ContractReceiptScheduled
        {
            get
            {
                return _contractReceiptScheduled ?? (_contractReceiptScheduled = _context.AlertTypes.FirstOrDefault(alertType => alertType.Id == 40));
            }
        }

        private AlertType _leaseOrderEngagedLeaseContract;

        /// <summary>
        /// </summary>
        public AlertType LeaseOrderEngagedLeaseContract
        {
            get
            {
                return _leaseOrderEngagedLeaseContract ?? (_leaseOrderEngagedLeaseContract = _context.AlertTypes.FirstOrDefault(alertType => alertType.Id == 100));
            }
        }

        private AlertType _leaseContractReceiptScheduled;

        /// <summary>
        /// </summary>
        public AlertType LeaseContractReceiptScheduled
        {
            get
            {
                return _leaseContractReceiptScheduled ?? (_leaseContractReceiptScheduled = _context.AlertTypes.FirstOrDefault(alertType => alertType.Id == 110));
            }
        }

        #endregion

        #region Constructors

        /// <summary>
        /// </summary>
        /// <param name = "context"></param>
        public AlertTypeEnum(EstateNukeCore context)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }
            _context = context;
        }

        #endregion
    }
}